// 表格数据导出为excel
import * as XLSX from "xlsx";
import FileSaver from 'file-saver'
export function excelData(id, name) {
  let xlsxParam = {
    raw: true
  }
  let wb = XLSX.utils.table_to_book(document.querySelector(`#${id}`), xlsxParam)
  let wbout = XLSX.write(wb, {
    bookType: 'xlsx',
    bookSST: true,
    type: 'array'
  })
  try {
    FileSaver.saveAs(new Blob([wbout], {
      type: 'application/octet-stream'
    }), `${name}.xlsx`)
  } catch (e) {
    if (typeof console !== 'undefined') {
      console.log(e, wbout)
    }
  }
  return wbout
}
